package com.season.seasonStudy;

import org.springframework.util.ObjectUtils;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.regex.Pattern;

public class TTTT {

    public static void main(String[] args) throws ParseException {
        String factdate = String.valueOf(new Date().getTime());
        if (!ObjectUtils.isEmpty(factdate)) {
            Pattern onlyNumberPattern = Pattern.compile("^[-\\+]?[\\d]*$");
            boolean matches = onlyNumberPattern.matcher(factdate).matches();
            try {
                if (matches){
                    Date date = new Date(Long.valueOf(factdate));
                    System.out.println(date);
                }else {
                    System.out.println(new SimpleDateFormat().parse(factdate));
                }
            }catch (Exception e){
                e.printStackTrace();
            }
        }

    }
}
